package com.cuijiao.emp.java.model;

import java.io.Serializable;
import java.util.Date;

import com.cuijiao.emp.java.util.DateUtil;

public class Emp implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -7634935680203673987L;

    private String empName;

    private String empNo;

    private double salary;

    private boolean sex;

    private Date birthday;

    /**
     * default constructor
     */
    public Emp() {

    }

    /**
     * max constructor
     */
    public Emp(String empName, String empNo, double salary, boolean sex, Date birthday) {
        this.empName = empName;
        this.empNo = empNo;
        this.salary = salary;
        this.sex = sex;
        this.birthday = birthday;
    }

    /**
     * min constructors
     */
    public Emp(String empNo) {
        this.empNo = empNo;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public String getEmpNo() {
        return empNo;
    }

    public void setEmpNo(String empNo) {
        this.empNo = empNo;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public boolean isSex() {
        return sex;
    }

    public void setSex(boolean sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((empNo == null) ? 0 : empNo.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Emp other = (Emp) obj;
        if (empNo == null) {
            if (other.empNo != null)
                return false;
        } else if (!empNo.equals(other.empNo))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Emp [ 姓名：" + empName + ", 员工号：" + empNo + ", 薪资：" + salary + ", 性别：" + (sex ? "男" : "女") + ", 生日：" + DateUtil.date2Sring(birthday) + "]";
    }

}
